{% extends 'layout.html' %}
{% block title %}{{ station.station_name }}{% endblock %}
{% block content %}
<div class="row">
    <div class="col">
        <table class="table table-striped">
            <tr>
                <td>换电站名称</td>
                <td><a href="/ai_inspect/station_update/{{station.station_id}}/">{{ station.station_name }}</a></td>
            </tr>
            <tr>
                <td>事业部</td>
                <td>{{ station.business_unit }}</td>
            </tr>
            <tr>
                <td>换电站厂家</td>
                <td>{{ station.station_maker }}</td>
            </tr>
            <tr>
                <td>换电站型号</td>
                <td>{{ station.station_type.station_model }}</td>
            </tr>
            <tr>
                <td>站控类型</td>
                <td>{{ station.get_software_version_display }}</td>
            </tr>
            <tr>
                <td>换电机器人类型</td>
                <td>{{ station.robot_type.robot_type }}</td>
            </tr>
            <tr>
                <td>视频推理机序列号</td>
                <td>{% if aibox %}
                    <a href="/ai_inspect/aibox_update/{{station.station_id}}">{{ aibox.aibox_sn }}</a>
                    {% else %}
                    <a role="button" class="btn btn-info" href="/ai_inspect/aibox_create/{{station.station_id}}/">添加视频推理机</a>
                    {% endif %}
                </td>
            </tr>
            <tr>
                <td>视频推理机</td>
                <td>
                    {% if aibox %}
                    <a target="_blank" href="{{ aibox.aibox_url }}">{{ aibox.aibox_url }}</a>
                    {% else %}
                    <a role="button" class="btn btn-info" href="/ai_inspect/aibox_create/{{station.station_id}}/">添加视频推理机</a>
                    {% endif %}
                </td>
            </tr>
            <tr>
                <td>是否支持智能巡检</td>
                <td>{{ aibox.ai_inspect|yesno:"是,否" }}</td>
            </tr>
            <tr>
                <td>监控通道</td>
                <td>{{ monitor_channel.channel_name }}</td>
            </tr>
        </table>
    </div>
</div>
<div class="row">
    <div class="col" align="center">
        <h2>监控摄像头列表</h2>
        <div align="right">
            <a role="button" class="btn btn-primary" href="/ai_inspect/channel_create/{{station.station_id}}">添加摄像头</a>
        </div>
    </div>
</div>
<div class="row">
    <div class="col">
        {% if channels %}
        <table class="table table-striped">
            <th>通道号</th>
            <th>通道名称</th>
            <th>通道地址</th>
            <th>算法</th>
            <th>手动抓图</th>
            {% for channel in channels %}
            <tr>
                <td><a href="/ai_inspect/channel_update/{{station.station_id}}/{{channel.channel_id}}">{{ channel.channel_number }}</a></td>
                <td>{{ channel.channel_name }}</td>
                <td>{{ channel.channel_ip }}</td>
                <td>{{ channel.channel_algorithm }}</td>
                <td>
                    <a role="button" target="new" class="btn btn-info" href="http://43.137.4.113:6002/manual_inspect?station_id={{station.station_id}}&channel_number={{channel.channel_number}}">发起</a>
                </td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="alert alert-danger" role="alert">未配置监控摄像头</div>
        {% endif %}
    </div>
</div>
<div class="row">
    <div class="col" align="center">
        <h2>基于换电步骤的巡检规则</h2>
        <div align="right">
            <a role="button" class="btn btn-primary" href="/ai_inspect/step_rule_create/{{station.station_id}}">添加规则</a>
        </div>
    </div>
</div>
<div class="row">
    <div class="col">
        {% if step_rules %}
        <table class="table table-striped">
            <th>巡检名称</th>
            <th>监控通道名称</th>
            <th>换电步骤码</th>
            <th>换电步骤名称</th>
            <th>是否启用</th>
            {% for step_rule in step_rules %}
            <tr>
                <td><a href="/ai_inspect/step_rule_update/{{step_rule.station_id}}/{{step_rule.rule_id}}/">{{ step_rule.algorithm.algorithm_name }}</a></td>
                <td>{{ step_rule.channel.channel_name }}</td>
                <td>{{ step_rule.step.step_code }}</td>
                <td>{{ step_rule.step.step_description }}</td>
                <td>{{ step_rule.activate|yesno:"启用,禁用" }}</td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="alert alert-danger" role="alert">未配置基于换电步骤的巡检规则</div>
        {% endif %}
    </div>
</div>
<div class="row">
    <div class="col" align="center">
        <h2>基于周期的巡检规则</h2>
        <div align="right">
            <a role="button" class="btn btn-primary" href="/ai_inspect/period_rule_create/{{station.station_id}}">添加规则</a>
        </div>
    </div>
</div>
<div class="row">
    <div class="col">
        {% if period_rules %}
        <table class="table table-striped">
            <th>巡检名称</th>
            <th>监控通道名称</th>
            <th>巡检周期</th>
            <th>是否启用</th>
            {% for period_rule in period_rules %}
            <tr>
                <td><a href="/ai_inspect/period_rule_update/{{station.station_id}}/{{period_rule.rule_id}}/">{{ period_rule.algorithm.algorithm_name }}</a></td>
                <td>{{ period_rule.channel.channel_name }}</td>
                <td>{{ period_rule.period }}</td>
                <td>{{ period_rule.activate|yesno:"启用,禁用" }}</td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="alert alert-danger" role="alert">未配置周期性巡检规则</div>
        {% endif %}
    </div>
</div>

<div class="row">
    <div class="col" align="center">
        <a role="button" class="btn btn-info" href="/swap_records/{{station.station_id}}">查看换电记录</a>
    </div>
    <div class="col" align="center">
        <a role="button" class="btn btn-info" href="/station_photo/{{station.station_id}}">查看换电站照片</a>
    </div>
</div>
{% endblock %}